package edu.ar.modulo3.perist.factory;

import java.io.IOException;
import java.util.Properties;

import edu.ar.modulo3.perist.dao.IAvionDAO;
import edu.ar.modulo3.perist.dao.IClienteDAO;
import edu.ar.modulo3.perist.dao.IEmpleadoDAO;
import edu.ar.modulo3.perist.dao.IReservaDAO;
import edu.ar.modulo3.perist.dao.IUsuarioDAO;
import edu.ar.modulo3.perist.dao.IVueloDAO;



public abstract class BaseDAOFactory {
	
	private static final int JDBC_IMPL = 1;
	private static final int FILE_IMPL = 2;
	private static final int HIBERNATE_IMPL = 3;
	
	private static Properties _conf;
	
	static {
		_conf = new Properties();
		try {
			_conf.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("db.properties"));
			
		} catch (IOException e) {
			
			e.printStackTrace();
		}
	}
	
	public BaseDAOFactory(){		
	}
	
	public static BaseDAOFactory getInstance() {
		
		BaseDAOFactory instance = null;
		
		switch( Integer.valueOf( _conf.getProperty("dbms") ) ) {
			
			case JDBC_IMPL: instance = new JdbcDAOFactoryImpl(); break;
			//case FILE_IMPL: instance = new FileDAOFactoryImpl(); break;
			case HIBERNATE_IMPL: instance = new HibernateDAOFactoryImpl(); break;
		}
		
		return instance;
	}

	public abstract IEmpleadoDAO getEmpleadoDAO();
	public abstract IClienteDAO getClienteDAO();
	public abstract IUsuarioDAO getUsuarioDAO();
	public abstract IReservaDAO getReservaDAO();
	public abstract IVueloDAO getVueloDAO();
	public abstract IAvionDAO getAvionDAO();
}
